﻿using System.Collections.Generic;
using LitJson;

#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
public static class RedDotEditorUtil
{

#if UNITY_EDITOR
    public static List<string> GetNodeTreeList()
    {
        var excelPath = Application.dataPath + "/" + "../../Configs/GameConfig/Datas/red_dot.xls";
        var excel = Excel.LoadExcel(excelPath);
        if (excel == null)
        {
            Debug.LogError("没有找到excel："+ excelPath);
            return null;
        }
        var sheet = excel.workbook.GetSheet("red_dot");
        if(sheet == null)
        {
            Debug.LogError("没有找到excel的Sheet：red_dot");
            return null;  
        }
        List<string> paths = new List<string>();
        for (int i=4; i<=sheet.LastRowNum; ++i)
        {
            var str = excel.GetCell(sheet, i, 2);
            paths.Add(str);
        }
        //LuaState luaState = new LuaState();

        //string sceneFile = Application.dataPath + "/Lua/Core/Global/";
        //luaState.AddSearchPath(sceneFile);
        //string luaFile = "RedDotEnum";

        //List<string> list = new List<string>();
        //try
        //{
        //    luaState.Require(luaFile);
        //    LuaTable table = luaState.GetTable("RedDotEnum");
        //    var dicTabel = table.ToDictTable();

        //    foreach (var i in dicTabel)
        //    {
        //        list.Add(i.Value.ToString());
        //    }
        //}
        //catch
        //{
        //    Debug.LogError("RedDotList parse error !! we can't found the file or not correct value in here \""+ sceneFile  + luaFile + ".lua\"");
        //}
        //luaState.Dispose();//使用完毕回收虚拟机
        //return list;
        //}
        return paths;
#endif
    }
}